package com.xgkj.diyiketang.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.xgkj.diyiketang.R;
import com.xgkj.diyiketang.util.ImageCache;
import com.xgkj.diyiketang.util.PalLog;
import com.xgkj.diyiketang.util.ViewUtil;

/**
 * Created by XCKJ_Paladowow on 2016/8/23.
 */
public class GoodsDetailActivity  extends BaseActivity{
    private Context mContext;
    private TextView back;
    private ImageView tijiaoBtn;
    private String goodsId;
    private String goodsName;
    private String goodsPrice;
    private String goodsImage;
    private String desc;

    private TextView mNameText;
    private TextView mPriceText;
    private ImageView mGoodsImage;
    private TextView mDescText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.goods_detail);
        mContext = this;
        initView();
    }

    private void initView(){
        Intent intent = getIntent();
        if(intent!=null){
            goodsId = intent.getStringExtra("ID");
            goodsName = intent.getStringExtra("NAME");
            goodsPrice = intent.getStringExtra("PRICE");
            goodsImage = intent.getStringExtra("IMAGE");
            desc = intent.getStringExtra("DESC");
        }
        back = (TextView) findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mNameText = (TextView) findViewById(R.id.goods_name);
        mNameText.setText(goodsName);

        mPriceText = (TextView) findViewById(R.id.goods_price);
        mPriceText.setText(goodsPrice);

        mGoodsImage = (ImageView) findViewById(R.id.goods_img);
        if (goodsImage != null && goodsImage.length() > 0) {
            ImageCache.getInstance(mContext).loadBitmapToView(mGoodsImage, goodsImage, null);

        }

        mDescText = (TextView) findViewById(R.id.goods_desc);
        mDescText.setText(desc);
        tijiaoBtn = (ImageView) findViewById(R.id.lijiduihuan);
        tijiaoBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext,SubmitOrderActivity.class);
                intent.putExtra("ID",goodsId);
                intent.putExtra("NAME",goodsName);
                intent.putExtra("IMAGE",goodsImage);
                intent.putExtra("PRICE",goodsPrice);
                startActivity(intent);
            }
        });
    }
}
